<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;

class CartController extends Controller
{
    //
    public function index(Request $request)
    {
    	$num = $request -> input('num',10);
        $keywords = $request -> input('keywords','');
        $data = DB::table('cart') -> where('uname','like','%'.$keywords.'%') -> paginate($num);
        
        foreach ($data as $k => $v) {
        	$arr = DB::table('goods') -> where('gid', $data[$k] -> gid) -> first();
        	$data[$k] -> gname = $arr -> gname;
        	$data[$k] -> gpic = $arr -> gpic;
        }
       	// dd($data);
        return view('admin.cart.index',['data' => $data ,'request' => $request -> all(), 'title' => '购物车列表']);
    }

    public function insert(Request $request)
    {
        
    }
}
